package communication;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class SocketConnection {

	private Socket socket;
	private RequestOutputStream out;
	private RequestInputStream in;

	public SocketConnection(Socket socket) throws IOException {
		this.socket = socket;
		out = new RequestOutputStream(socket.getOutputStream());
		in = new RequestInputStream(socket.getInputStream());
	}

	public void writeRequest(Request request) throws IOException {
		out.writeRequest(request);
	}

	public Request readRequest() throws IOException, ClassNotFoundException {
		return in.readRequest();
	}

	public void close() throws IOException {
		socket.close();
	}

	public InputStream getInputStream() {
		
		return in;
	}
	
	public OutputStream getOutputStream(){
		return out;
	}
}
